<script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery.min.js" charset="UTF-8"></script>
 <script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery.easyui.min.js" charset="UTF-8"></script>
 <link rel="stylesheet" href="../js/jquery-easyui-1.3.5/themes/default/easyui.css" type="text/css"></link>
 <link rel="stylesheet" href="../js/jquery-easyui-1.3.5/themes/icon.css" type="text/css"></link>
 <link rel="stylesheet" href="../css/main.css" type="text/css"></link>
 <script type="text/javascript" src="../js/mine.js"></script>
 <script type="text/javascript" src="../js/jquery-easyui-1.3.5/locale/easyui-lang-zh_CN.js" charset="UTF-8"></script>
	 
<script type="text/javascript" charset="UTF-8">
	var allProjectDatagrid;
	var allProjectLayout;
	var allProjectForm;
	var projectDetailADialog;
	$(function(){
		allProjectForm = $('#allProjectForm').form();
		allProjectLayout = $('#allProjectLayout').layout();
		allProjectDatagrid = $('#allProjectDatagrid').datagrid({
			url:'../servlet/GetTAllProjectServlet',
			//iconCls:'icon-save',
			fitColumns:true,
			nowrap:false,
			striped:true,
			idField:'pno',
			//rownumbers:true,
			pagination:true,
			pageSize:10,
			pageList:[10,20,30],
			fit:true,
			border:false,
			sortName:'pno',
			sortOrder:'desc',
			columns:[[ {
				title:'项目编号',
				field:'pno',
				width:100,
				sortable:true,
				checkbox:true,
			},{
				title:'项目名称',
				field:'pname',
				width:80,
				sortable:true,
				formatter: function(value,rowData,rowIndex){
		            return '<a href="javascript:void(0);" onclick="showProjectDetail(' + rowIndex + ');" style="text-decoration: none;">'+value+'</a>';
		     	}  	
			},{
				title:'创建时间',
				field:'stime',
				width:45,
				sortable:true
			},{
				title:'截止时间',
				field:'etime',
				width:45,
				sortable:true
			},{
				title:'发布者',
				field:'pubname',
				width:40
			},{
				title:'项目状态',
				field:'progress',
				sortable:true,
				width:40,
				formatter: function(value,rowData,rowIndex){
					if(value == '1') {
						return '已完成';
					} else {
						return '进行中';
					}
		     	} 
			},{
				title:'讨论区',
				field:'discuss',
				width:50,
				formatter: function(value,rowData,rowIndex){
		            return '<a href="javascript:void(0);" onclick="showDiscuss(' + rowIndex + ');">'+ value +'</a>';
		     	}  
			},{
				title:'成果区',
				field:'show',
				width:50,
				formatter: function(value,rowData,rowIndex){
					 return '<a href="javascript:void(0);" onclick="showAchieve(' + rowIndex + ');">' + value +'</a>';
		     	}  
			}]],
			toolbar:[{
				text:'取消',
				iconCls:'icon-undo',
				handler:function(){
					allProjectDatagrid.datagrid('unselectAll');
					allProjectDatagrid.datagrid('rejectChanges');
				}
			},'-',{
				text:'刷新',
				iconCls:'icon-reload',
				handler:function(){
					allProjectDatagrid.datagrid('unselectAll');
					allProjectDatagrid.datagrid('rejectChanges');
					allProjectDatagrid.datagrid('load');
				}
			},'-']
		});
		
		$('#progress').combobox({
			data:[{
				"id":"all",
				"text":"全部",
			},{
				"id":"0",
				"text":"进行中"
			},{
				"id":"1",
				"text":"已完成",
			}],
			valueField:'id',
			textField:'text',
			editable:false
		});
	});
	
	showDiscuss = function(i) {
		allProjectDatagrid.datagrid('unselectAll');
		allProjectDatagrid.datagrid('rejectChanges');
		
		var rows = allProjectDatagrid.datagrid('getRows');
		console.info(rows[i]);
		
		var menuTab = parent.$('#menuTab', parent.document).tabs();//得到tabs对象
		var tabText = '讨论区_' + rows[i].pname;
		var tabUrl = 'teacher/discuss.jsp?pno=' + rows[i].pno;
		//console.info(menuTab);
		if(menuTab.tabs('exists', tabText)) {
			menuTab.tabs('select', tabText);
		} else {
			menuTab.tabs('add',{
				title: tabText,
				closable:true,
				//content:tabText
				content:'<iframe src="'+ tabUrl +'" frameborder="0" style="border:0;width:100%;height:100%;"></iframe>'
			});
		}
		
	}
	
	showAchieve = function(i) {
		allProjectDatagrid.datagrid('unselectAll');
		allProjectDatagrid.datagrid('rejectChanges');
		
		var rows = allProjectDatagrid.datagrid('getRows');
		
		var menuTab = parent.$('#menuTab', parent.document).tabs();//得到tabs对象
		var tabText = '成果区_' + rows[i].pname;
		var tabUrl = 'teacher/achivement.jsp?pno=' + rows[i].pno;
		//console.info(menuTab);
		if(menuTab.tabs('exists', tabText)) {
			menuTab.tabs('select', tabText);
		} else {
			menuTab.tabs('add',{
				title: tabText,
				closable:true,
				//content:tabText,
				content:'<iframe src="'+ tabUrl +'" frameborder="0" style="border:0;width:100%;height:100%;"></iframe>'
			});
		}
		
	}
	
	showProjectDetail = function(i) {
		var rows = allProjectDatagrid.datagrid('getRows');
		var title = '项目详情_' + rows[i].pname;
		console.info(title);
		projectDetailADialog = parent.$('#projectDetailDialog', parent.document).dialog({
			title:title,
			modal:true,
			collapsible:false,
			showHeader:false,
			width:600,
			height:550,
			href:'teacher/projectDetail.jsp?pno=' + rows[i].pno
		});
		
		projectDetailADialog.dialog('open');
	}
	
	searchProject = function() {
		console.info(serializeObject(allProjectForm));
		allProjectDatagrid.datagrid('load',serializeObject(allProjectForm));
	}

	cleanProject = function() {
		allProjectDatagrid.datagrid('load',{});
		allProjectForm.find('input').val('');
	}
</script>

<div id="allProjectLayout" fit="true" border="false" >
		<div region="north" border="false" split="false" title="查询" style="margin:0 auto;height:81px;" >
			<form id="allProjectForm"  class="datagrid-toolbar" style="margin:0 auto;">
				<table>
					<tr>
						<td><b>项目名称</b><input type="text" name="pname" id="pname"/></td>
						<td ><b>创建时间</b><input type="text" name="stimef" id="stimef" class="easyui-datetimebox" />-</td>
						<td><input type="text" name="stimet" id="stimet" class="easyui-datetimebox" /></td>
						<td><b>项目进度</b><input type="text" name="progress" id="progress"/></td>
					</tr>
					<tr>
						<td><b>&nbsp;&nbsp;&nbsp;&nbsp;发布者</b><input type="text" name="pubname" id="pubname"/></td>
						<td><b>截止时间</b><input type="text" name="etimef" id="etimef" class="easyui-datetimebox" />-</td>
						<td><input type="text" name="etimet" id="etimet" class="easyui-datetimebox" /></td>
						<td>
							<a href="javascript:void(0);" style="vertical-align:middle;" class="easyui-linkbutton"  iconCls="icon-search" pain="false" onclick="searchProject();" ></a>
						<!-- </td>
						<td> -->
							<a href="javascript:void(0);" style="vertical-align:middle;" class="easyui-linkbutton"  pain="false" onclick="cleanProject();" >清空</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
	<div region="center" border="false" >
		<table id="allProjectDatagrid"></table>
	</div>	
</div>

	
